package com.dkd.handler;

import cn.elegent.ac.ACHandler;
import cn.elegent.ac.annotation.Topic;
import com.dkd.config.TopicConfig;
import com.dkd.contract.SupplyContract;
import com.dkd.service.VendingMachineService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author DiXiaoNie
 * @since 2023/2/1 16:04
 */
@Topic(TopicConfig.VMS_SUPPLY_TOPIC)
public class SupplyMsgHandler implements ACHandler<SupplyContract> {

    @Autowired
    private VendingMachineService vmService;

    @Override
    public void process(String s, SupplyContract supplyContract) throws Exception {
        if (supplyContract == null || supplyContract.getSupplyData() == null) {
            return;
        }
        //更新售货机库存j
        this.vmService.supply(supplyContract);
    }
}
